package com.briup.ch08;

/**
 * @Author briup-adam
 * @Date 2023/10/17 下午5:09
 * @Description
 **/

public class Circle<A, B> {
    private A x;
    private A y;
    private B radius;

    public Circle(A x, A y, B radius) {
        this.x = x;
        this.y = y;
        this.radius = radius;
    }

    public A getX() {
        return x;
    }

    public void setX(A x) {
        this.x = x;
    }

    public A getY() {
        return y;
    }

    public void setY(A y) {
        this.y = y;
    }

    public B getRadius() {
        return radius;
    }

    public void setRadius(B radius) {
        this.radius = radius;
    }

    public Circle() {
    }
}

class CircleTest {

    public static void main(String[] args) {
//实例化泛型类对象:
// 泛型类<具体类型1,具体类型2,...> 对象 = new 泛型类<>(实 参s);
//1.实例化具体类对象，2种泛型设置为Integer和Double
// 注意，泛型类可以是任意引用类型
        Circle<Integer, Double> c1 = new Circle<>(2, 3, 2.5);
        int x = c1.getX();
        double r = c1.getRadius();
        System.out.println("x: " + x + " radius: " + r);
        System.out.println("------------------");
//2.实例化具体类对象，2种泛型设置为Double和Integer
        Circle<Double, Integer> c2 = new Circle<>(2.0, 3.0, 2);
        double x2 = c2.getX();
        int r2 = c2.getRadius();
        System.out.println("x2: " + x2 + " r2: " + r2);
    }

}
